]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
cleanup: Use spread properties instead of Object.assign()
authorFlorian Müllner <fmuellner@gnome.org>
Wed, 25 Mar 2020 00:00:56 +0000 (01:00 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Sat, 17 Feb 2024 10:53:43 +0000 (11:53 +0100)
It's more concise and has been around long enough to embrace it.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3196>

js/misc/params.js
js/ui/barLevel.js
js/ui/dialog.js
js/ui/dnd.js
js/ui/environment.js
js/ui/lightbox.js
js/ui/shellEntry.js

index 8eb6eeb21c8fab082daca16024fdd2851e42653c..3ff8480d2a9abf12a21d22eab13f150a6fd84cdb 100644 (file)
@@ -25,6 +25,5 @@ export function parse(params = {}, defaults, allowExtras) {
         }
     }
 
-    let defaultsCopy = Object.assign({}, defaults);
-    return Object.assign(defaultsCopy, params);
+    return {...defaults, ...params};
 }
index 1b4b7f940311d422df60d16da1865b65eba59256..3f4535725d8b08248e72f449f1abcf89e2d0116d 100644 (file)
@@ -38,11 +38,11 @@ export const BarLevel = GObject.registerClass({
         this._barLevelActiveBorderColor = null;
         this._barLevelOverdriveBorderColor = null;
 
-        let defaultParams = {
+        super._init({
             style_class: 'barlevel',
             accessible_role: Atk.Role.LEVEL_BAR,
-        };
-        super._init(Object.assign(defaultParams, params));
+            ...params,
+        });
         this.connect('notify::allocation', () => {
             this._barLevelWidth = this.allocation.get_width();
         });
index bb008420358c6adbdf60414619aae092add3e27b..11a27a02070d9ebaceb880e36d8bd65fef7a59f8 100644 (file)
@@ -176,12 +176,12 @@ export const MessageDialogContent = GObject.registerClass({
         this._description.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
         this._description.clutter_text.line_wrap = true;
 
-        let defaultParams = {
+        super._init({
             style_class: 'message-dialog-content',
             x_expand: true,
             vertical: true,
-        };
-        super._init(Object.assign(defaultParams, params));
+            ...params,
+        });
 
         this.connect('notify::size', this._updateTitleStyle.bind(this));
         this.connect('destroy', this._onDestroy.bind(this));
@@ -269,12 +269,12 @@ export const ListSection = GObject.registerClass({
             child: this.list,
         });
 
-        let defaultParams = {
+        super._init({
             style_class: 'dialog-list',
             x_expand: true,
             vertical: true,
-        };
-        super._init(Object.assign(defaultParams, params));
+            ...params,
+        });
 
         this.label_actor = this._title;
         this.add_child(this._title);
@@ -327,8 +327,10 @@ export const ListSectionItem = GObject.registerClass({
         textLayout.add_child(this._title);
         textLayout.add_child(this._description);
 
-        let defaultParams = {style_class: 'dialog-list-item'};
-        super._init(Object.assign(defaultParams, params));
+        super._init({
+            style_class: 'dialog-list-item',
+            ...params,
+        });
 
         this.label_actor = this._title;
         this.add_child(this._iconActorBin);
index 22e45766c29cb84da65c86121c41a25edcff2bc6..ea904ff423c8c313acb66502f82abe84a07c9af2 100644 (file)
@@ -795,13 +795,14 @@ class _Draggable extends Signals.EventEmitter {
         this._animationInProgress = true;
 
         // start the animation
-        this._dragActor.ease(Object.assign(params, {
+        this._dragActor.ease({
+            ...params,
             opacity: this._dragOrigOpacity,
             mode: Clutter.AnimationMode.EASE_OUT_QUAD,
             onComplete: () => {
                 this._onAnimationComplete(this._dragActor, eventTime);
             },
-        }));
+        });
     }
 
     _finishAnimation() {
index 4eea5f13ff8f4d18af2cb84a49fc7ac9c2f9478c..6a2b60864293f04512d49fac38e39e696ce09a2c 100644 (file)
@@ -211,13 +211,14 @@ function _easeActorProperty(actor, propName, target, params) {
     }
 
     let pspec = actor.find_property(propName);
-    let transition = new Clutter.PropertyTransition(Object.assign({
+    let transition = new Clutter.PropertyTransition({
         property_name: propName,
         interval: new Clutter.Interval({value_type: pspec.value_type}),
         remove_on_complete: true,
         repeat_count: repeatCount,
         auto_reverse: autoReverse,
-    }, params));
+        ...params,
+    });
     actor.add_transition(propName, transition);
 
     transition.set_to(target);
index 577484137668d3d7e51dcb931787a0871c0d4b3d..199f562f8709c062abc12d65087bb46d8ea09aa0 100644 (file)
@@ -209,12 +209,13 @@ export const Lightbox = GObject.registerClass({
                 '@effects.radial.brightness', VIGNETTE_BRIGHTNESS, easeProps);
             this.ease_property(
                 '@effects.radial.sharpness', VIGNETTE_SHARPNESS,
-                Object.assign({onComplete}, easeProps));
+                {onComplete, ...easeProps});
         } else {
-            this.ease(Object.assign(easeProps, {
+            this.ease({
+                ...easeProps,
                 opacity: 255 * this._fadeFactor,
                 onComplete,
-            }));
+            });
         }
     }
 
@@ -235,9 +236,9 @@ export const Lightbox = GObject.registerClass({
             this.ease_property(
                 '@effects.radial.brightness', 1.0, easeProps);
             this.ease_property(
-                '@effects.radial.sharpness', 0.0, Object.assign({onComplete}, easeProps));
+                '@effects.radial.sharpness', 0.0, {onComplete, ...easeProps});
         } else {
-            this.ease(Object.assign(easeProps, {opacity: 0, onComplete}));
+            this.ease({...easeProps, opacity: 0, onComplete});
         }
     }
 
index 65c811168e6f64e1e175a42929ed95b8b6d6406c..3c924f42fb6ea894eddb53922eb9120bca703605 100644 (file)
@@ -168,8 +168,10 @@ export function addContextMenu(entry, params) {
 export const CapsLockWarning = GObject.registerClass(
 class CapsLockWarning extends St.Label {
     _init(params) {
-        let defaultParams = {style_class: 'caps-lock-warning-label'};
-        super._init(Object.assign(defaultParams, params));
+        super._init({
+            style_class: 'caps-lock-warning-label',
+            ...params,
+        });
 
         this.text = _('Caps lock is on.');